#!/bin/bash

JAR_NAME="ABK-Server-1.0.1.jar"
PID_FILE="server.pid"
PID_TMP_FILE="server.tmp.pid"
#进程文件若存在，则删除
if [ -f "$PID_FILE" ]
then
  rm -f $PID_FILE
fi
if [ -f "$PID_TMP_FILE" ]
then
  rm -f $PID_TMP_FILE
fi

echo $(ps -ef | grep $JAR_NAME) > ${PID_TMP_FILE}
echo $(awk '{print $2}' $PID_TMP_FILE) > ${PID_FILE}